function saveText() {
    const textBox = document.querySelector('.text-box');
    const textToSave = textBox.textContent.trim();

    if (textToSave) {
        // Save the text to local storage for demonstration purposes
        localStorage.setItem('savedText', textToSave);
        alert('Text saved successfully!');
    } else {
        alert('No text to save.');
    }
}
document.getElementById('search').addEventListener('keydown', function(event) {
    if (event.key === 'Enter') {
        // Trigger search logic here
    }
});
const GUA_NAME = ['乾', '姤', '遁', '否', '观', '剥', '晋', '大有', '震', '豫', '解', '恒', '升', '井', '大过', '随','坎', '节', '屯', '既济', '革', '丰', '明夷', '师', '巽', '小畜', '家人', '益', '无妄', '噬嗑', '颐', '蛊',    '艮', '贲', '大畜', '损', '睽', '履', '中孚', '渐', '坤', '复', '临', '泰', '大壮', '夬', '需', '比',    '离', '旅', '鼎', '未济', '蒙', '涣', '讼', '同人', '兑', '困', '萃', '咸', '蹇', '谦', '小过', '归妹'];
const time = document.getElementById("time");
const coinNum = document.getElementById("coinNum");

// 监听time的输入事件
time.addEventListener('input', function() {
    const value = this.value.toLowerCase();
    const indexes = [];

    // 创建一个正则表达式来匹配GUA_NAME数组中的单词
    const regex = new RegExp(GUA_NAME.map(fruit => `(${fruit})`).join('|'), 'g');
    let match;
    while ((match = regex.exec(value)) !== null) {
        const fruitIndex = GUA_NAME.indexOf(match[0]);
        if (fruitIndex !== -1) {
            indexes.push(fruitIndex);
        }
    }

    // 只有当indexes有数值时，才改动coinNum的值
    if (indexes.length > 0) {
        coinNum.value = indexes.join(' ');
    }
});
